﻿<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="App=Equipment.Business.Application" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Posting
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="CurrentMenuIDContent" runat="server" >woMenu</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
    <link rel="stylesheet" type="text/css" href="../../Content/jquery-ui-1.8.16.custom.css" />
    <script type="text/javascript" src="../../Scripts/site.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery-ui-1.8.16.custom.min.js"></script>
    <script src="<%= Url.Content("~/Scripts/MicrosoftAjax.js") %>" type="text/javascript"></script>
    <script src="<%= Url.Content("~/Scripts/MicrosoftMvcAjax.js") %>" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Work Order Posting</h2>
    <br />
    <% Using Html.BeginForm()%>
    <%= Html.ValidationSummary(False) %>
    <table>
        <tr>
            <td width="130px">
                Filter By Asset Type:
            </td>
            <td width="210px">
                <%= Html.DropDownList("AssetType", "---All---")%>
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td>
                Filter By Departments:
            </td>
            <td>
                <%= Html.DropDownList("Department", "---All---")%>
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td>
                Filter By Due Date:
            </td>
            <td>
                <span style="margin-top:9px;" class="left">From&nbsp;</span>
                <div class="calendar-field">
                    <%= Html.TextBox("txtDateFrom", ViewData("DateFrom"), New With {.class = "text date-input"})%>
                </div>
            </td>
            <td>
                <span style="margin-top:9px;" class="left">To&nbsp;</span>
                <div class="calendar-field">
                    <%= Html.TextBox("txtDateTo", ViewData("DateTo"), New With {.class = "text date-input"})%>
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="3">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <div id="postingGridContent">
                    <% Html.RenderPartial("~/Views/WorkOrder/Controls/PostingWorkOrderGrid.ascx")%>
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <input id="btnPost" type="submit" class="button" style="width: 400px;" value="Post Selected Work Orders" onclick = "return AuthenticationForWorkOrder()"/>
            </td>
        </tr>
    </table>
    
    <% Html.RenderPartial("~/Views/WorkOrder/Dialogs/WorkOrderAuthenticationDialog.ascx")%>
    <% End Using%>
    <script type="text/javascript">
        $(document).ready(function () {
            $("select").change(function () {
                setFilter();
            });

            $("#txtDateFrom, #txtDateTo").datepicker({
                showOn: "button",
                buttonImage: "../../Content/img/calendar.gif",
                buttonImageOnly: true,
                dateFormat: 'dd-M-yy',
                onSelect: setFilter
            });
        });
        
       

        function setFilter() {
            showLoading("postingGridContent", true);
            var assetTypeID = $("#AssetType").val();
            var locationID = $("#Department").val();
            var dateFrom = $("#txtDateFrom").val();
            var dateTo = $("#txtDateTo").val();
            jQuery.ajax({
                type: 'POST',
                data: { assetTypeID: assetTypeID,
                    locationID: locationID,
                    strDateFrom: dateFrom,
                    strDateTo: dateTo
                },
                url: '<%= Html.AttributeEncode(Url.Action("FilterPostingWorkOrder")) %>',
                success: function (result) {
                    $('#postingGridContent').html(result);
                    hideLoading("postingGridContent");
                }
            });
        }
    </script>
</asp:Content>
